package GUI.Controller;

import main.EventHandler;

public class Controller
{
	static EventHandler gui_handler;
	public static String[] GetHotels()
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String[] listOfHotels = gui_handler.getHotels();

		return listOfHotels;
	}
	
	public static String[][] GetBills(String bid){
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();
		return gui_handler.getBills(bid);
	}
	
	public static void PayBill(String bid, String amount){
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();
		gui_handler.payBills(bid, amount);
	}
	
	public static String getTotalCharge(String bid){

		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();
		return gui_handler.getTotalCharge(bid);
	}
	
	public static String getAmountPaid(String bid){

		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();
		return gui_handler.getAmountPaid(bid);
	}

	public static String[][] GetHotelsWithDetails()
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String[][] listOfHotels = gui_handler.getHotelsDetail();

		return listOfHotels;
	}

	public static String[] GetRoomTypes()
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String[] listOfRoomTypes = gui_handler.getRoomTypes();

		return listOfRoomTypes;
	}

	public static String[][] GetRoomTypesWithDetails()
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String[][] listOfRoomTypes = gui_handler.getRoomTypesDetail();

		return listOfRoomTypes;
	}

	public static String[][] GetRooms()
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String[][] listOfRooms = gui_handler.getRoom();

		return listOfRooms;
	}

	public static String[][] GetBookings(String hotelID, String status){
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String [][] listOfBookings = gui_handler.getBookingDetail(hotelID, status);
		return listOfBookings;
	}

	public static String[][] GetAvailableRooms(String [] input){
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		String [][] listOfAvailableRooms = gui_handler.getAvailableRooms(input);

		return listOfAvailableRooms;
	}


	public static String AddRoom(String[] data)
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		gui_handler.createRoom(data);

		return "Ok!";
	}

	public static String CreateHotel(String[] args)
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		gui_handler.createHotel(args);
		return "Ok!";
	}

	public static String CreateRoomType(String[] args)
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		gui_handler.createRoomType(args);
		return "Ok!";
	}

	public static String CreateCustomer(String[] args)
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		boolean success = gui_handler.createCustomer(args);
		return success ? "Ok!" : "Failed...";
	}

	public static String[] GetCustomer(String[] args)
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		return gui_handler.getCustomer(args);
	}

	// input[0] -> customerID
	// input[1] -> roomID
	// input[2] -> start_date
	// input[3] -> end_date
	public static boolean bookRoom(String[] query){
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();

		return gui_handler.bookRoom(query);
	}

	public static String ChangeBookingStatus(String bid, String status)
	{
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();
		gui_handler.changeBookingStatus(bid, status);
		return "Ok!";
	}

	public static int Login(String email, String password){
		if(gui_handler == null)
			gui_handler = EventHandler.getInstance();
		return gui_handler.login(email, password);
	}
	
	public static String[][] getAccounts(){
		if(gui_handler == null){
			gui_handler = EventHandler.getInstance();
		}
		return gui_handler.getAccount();
		
	}

	// String[] customerParams = { "LastName", "FirstName", "PsWd", "email",
	// "0", "address","4038888888", "0" };
	public static boolean CreateAccount(String[] accountParameters){
		if(gui_handler == null){
			gui_handler = EventHandler.getInstance();
		}
		return gui_handler.createCustomer(accountParameters);
	}
	
	public static int GetCustomerID(String email, String pswd){
		if(gui_handler == null){
			gui_handler = EventHandler.getInstance();
		}
		return gui_handler.getCustomerID(email, pswd);
	}
	
	// input[0] -> booking id
	// input[1] -> cost
	// input[2] -> description
	public static boolean AddCost(String bookID, String cost, String description){
		if(gui_handler == null){
			gui_handler = EventHandler.getInstance();
		}
		String[] input = {bookID, cost, description};
		return gui_handler.addRoomService(input);		
	}
	
	public static boolean CancelBooking(String bookID){
		if(gui_handler == null){
			gui_handler = EventHandler.getInstance();
		}
		return gui_handler.changeBookingStatus(bookID, "CANCELLED");
	}
}
